from django.db import models

from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    '''
    继承django 用户表以后，字段不需要重新写一遍
    '''
    phone = models.CharField(max_length=11, null=True, blank=True)

    class Meta:
        db_table = 'user'

    def __str__(self):
        return self.username


class Oauth2(models.Model):
    '''
    用户（绑定美多商城下边的那一个用户，可以为空）
    uid 绑定微博的uid
    来源
    '''
    SITE_TYPE_CHOICE = (
        (1, '微博'),
        (2, 'QQ'),
        (3, '微信')
    )
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    uid = models.CharField(max_length=20)
    site_type = models.IntegerField(choices=SITE_TYPE_CHOICE, default=1)

    class Meta:
        db_table='oauth2'












